<template>
  <view class="">
    <u-form-item
      :label="item.label"
      borderBottom
      ref="item1"
      :prop="item.value"
      :required="item.required"
    >

      <u-switch v-model="inputValue"   :activeValue="item.props.activeValue||'0'" :inactiveValue="item.props.inactiveValue||'1'"></u-switch>
    </u-form-item>
  </view>
</template>

<script>
export default {
  mixins: [uni.$u.mpMixin, uni.$u.mixin],
  data() {
    return {
      // inputValue: "",
      show: false,
    };
  },
  computed: {
    disabled() {
      this.getParentData("u-form")
      return this.parent.disabled;
    },
    // list() {
    //   return this.item.options.map((e) => {
    //     return {
    //       ...e,
    //       name: e.label,
    //     };
    //   });
    // },
    inputValue: {
      get() {
        if(this.value==''){
          this.$emit("input", this.item.props.inactiveValue||'1');
          return this.value;
        }
        return this.value;
      },
      set(val) {
        this.$emit("input", val);
        // this.inputValue = val;
      },
    },
  },
  props: {
    item: {
      typeof: Object,
      default: () => {
        return {};
      },
    },
    data: {
      typeof: Object,
      default: () => {
        return {};
      },
    },
    value: {
      typeof: [String, Number, Boolean, Array, Object],
      default: () => {
        return "";
      },
    },
  },

  methods: {
    blur() {
      this.$emit("input", this.inputValue);
      uni.$u.formValidate(this.$refs.formitem, "blur");
    },
    change(e) {
      this.$emit("input", this.inputValue);
      
    },
  },
};
</script>

<style scoped lang="scss">
.uni-input-input {
  font-size: 14px !important;
  color: #171a1d !important;
  line-height: 99rpx !important;
  height: 99rpx !important;
  padding-left: 10px;
}

.uni-forms-item__label {
  margin-left: 0;
  font-size: 14px !important;
  color: #171a1d !important;
  line-height: 99rpx !important;
  height: 99rpx !important;
}
</style>
